<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateGiftLogTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('gift_log', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->default(0)->comment('赠送用户ID');
            $table->integer('receive_user_id')->default(0)->comment('接收用户ID');
            $table->smallInteger('gift_id')->default(0)->comment('礼物ID');
            $table->string('order_id', 50)->default('')->comment('关联内部订单ID');
            $table->tinyInteger('flag')->default(1)->comment('0:未领取;1:已领取,金币到账;2:已过期;3:金币未到账');
            $table->index(['user_id', 'receive_user_id'], 'send_gift');
            $table->timestamp('fetch_at', 0)->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('gift_log');
    }
}
